#include <iostream>
#include "nnec/nnec_utils.h"

using namespace std;
using namespace NNEC;

double fun(double x, void *param);

int main()
{
    auto integrand = new INTEGRAND();
    int n = 5;
    integrand->parameter = (void *)(&n);
    integrand->function = fun;
    double result;
    double a = 0.34;
    double b = 1.3;
    int eval_count;

    int ret = integration_romberg(integrand, a, b, 20, 0.0, 1e-10, &result, &eval_count);

    double actual = pow(b, n+1) / double(n+1) - pow(a, n+1) / double(n+1);

    cout.precision(16);
    cout<< "Result=" << result << ", Actual=" << actual
        << ", Return Code=" << ret <<", Eval Count=" << eval_count << endl;

    return 0;
}

double fun(double x, void *param)
{
    int *n = (int *)param;
    double y = pow(x, double(*n));
    return y;
}

